package com.constant;

import lombok.Getter;
import org.springframework.util.StringUtils;

import java.util.Objects;

@Getter
public enum HandleEnum {
    ADD("add","添加"),
    UPDATE("update","修改"),
    DEL("del","删除"),
    QUERY("query","查询"),
    HANDLE("handle","处理"),
    ;
    private String code;
    private String name;

    HandleEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }
    public static HandleEnum codeOf(String code){
        if(StringUtils.isEmpty(code)){
            return null;
        }
        for(HandleEnum v:values()){
            if(Objects.equals(code,v.getCode())){
                return v;
            }
        }
        return null;
    }

}
